//
//  TimeMethod.m
//  WRY
//
//  Created by Yang on 9/1/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "TimeMethod.h"


@implementation TimeMethod
+ (NSString *)timeStringForString:(NSString *)string {
	NSMutableString *timeString = [[NSMutableString alloc] initWithString:string];
	[timeString setString:[timeString stringByReplacingOccurrencesOfString:@"/Date(" withString:@""]];
	[timeString setString:[timeString stringByReplacingOccurrencesOfString:@")/" withString:@""]];
	[timeString setString:[timeString substringToIndex:timeString.length - 3]];
	NSDate *date = [NSDate dateWithTimeIntervalSince1970:[timeString longLongValue]];
	NSDateFormatter *format = [[NSDateFormatter alloc] init];
	[format setDateFormat:@"yyyy-MM-dd HH:mm"];
	NSString *returned = [NSString stringWithFormat:@"%@",[format stringFromDate:date]];
	[format release];
	return returned;
	
}
+ (NSString *)dayAndTimeString:(NSString *)string {
	NSMutableString *timeString = [[NSMutableString alloc] initWithString:string];
	[timeString setString:[timeString stringByReplacingOccurrencesOfString:@"/Date(" withString:@""]];
	[timeString setString:[timeString stringByReplacingOccurrencesOfString:@")/" withString:@""]];
	[timeString setString:[timeString substringToIndex:timeString.length - 3]];
	NSDate *date = [NSDate dateWithTimeIntervalSince1970:[timeString longLongValue]];
	NSDateFormatter *format = [[NSDateFormatter alloc] init];
	[format setDateFormat:@"HH:mm"];
	NSString *returned = [NSString stringWithFormat:@"%@",[format stringFromDate:date]];
	[format release];
	return returned;
}
+(NSString *) stringDateByFormat:(NSDate *)date timeformat:(NSString *)dateFormate
{
    NSDateFormatter *format = [[NSDateFormatter alloc] init];
	[format setDateFormat:dateFormate];
	NSString *returned = [NSString stringWithFormat:@"%@",[format stringFromDate:date]];
	[format release];
	return returned;
}
@end
